/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * fondo.java
 *
 * Created on 15-oct-2011, 22:16:23
 */
package GUI;


import java.awt.*;

import javax.swing.*;

/**
 *
 * @author PUKI
 */
public class fondo extends javax.swing.JPanel {

    /** Creates new form fondo */
    String ruta;
    JFrame contenedor;
    public fondo() {
        initComponents();
        this.setSize(400,300);
        ruta="";
        
    }
    
    public fondo(int w, int h, String ruta, JFrame cont )
    {
        initComponents();
        this.ruta=ruta;
        this.setSize(w,h);
        contenedor=cont;
    }
    
      
    
    @Override
    public void paintComponent(Graphics g)
    {
        Dimension tam=getSize();
        ImageIcon ImagenFondo;
        if(ruta.equals(""))
        {
            ImagenFondo= new ImageIcon(new ImageIcon(getClass().getResource("/Imagenes/img.jpg")).getImage());
        }
        else
        {
            ImagenFondo= new ImageIcon(new ImageIcon(getClass().getResource(ruta)).getImage());
        }
            
        g.drawImage(ImagenFondo.getImage(), contenedor.getWidth()-tam.width/2,contenedor.getHeight()-tam.height/2, tam.width,tam.height,null);
        setOpaque(false);
        super.paintComponent(g);
    }
            

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
